package com.example.demo.controller;

import com.example.demo.bean.APIResponseBean;
import com.example.demo.bean.APIResponseBeanUtil;
import com.example.demo.service.MilvusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MilvusController {

    @Autowired
    private MilvusService milvusService;

    @PostMapping("/milvus/createCollection")
    public APIResponseBean createCollection() {
        milvusService.createCollection();
        return APIResponseBeanUtil.success();
    }

    @PostMapping("/milvus/insert")
    public APIResponseBean insert(@RequestBody String content) throws Exception {
        milvusService.insert(content);
        return APIResponseBeanUtil.success();
    }

    @PostMapping("/milvus/search")
    public APIResponseBean search(@RequestBody String content) throws Exception {

        return APIResponseBeanUtil.success(milvusService.search(content));
    }
}
